package com.ykt.controller;

import com.ykt.common.utils.UB;
import com.ykt.converter.CategoryConverter;
import com.ykt.model.Category;
import com.ykt.service.CategoryService;
import com.ykt.vo.CategoryVo;
import com.ykt.vo.ResultVo;

import java.util.List;

/**
 * 市场商品分类
 * @author long.hua
 * @version 1.0.0
 * @since 2016-05-27 23:11
 */
public class CategoryController extends BaseController{

    private CategoryService categoryService = enhance(CategoryService.class.getName(), CategoryService.class);

    public void find(){
        int userId = UB.i(getPara("userId"));
        int marktId = UB.i(getPara("marketId"));
        int pid = UB.i(getPara("pid"), 0);

        List<Category> categories = categoryService.findByPid(marktId, pid);

        List<CategoryVo> categoryVos = CategoryConverter.convert(categories);

        returnJson(ResultVo.success(categoryVos));
    }

}
